package com.sakura.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 *  后置处理器：初始化前后进行处理工作
 *  将后置处理器加入到容器中
 * @author Sakura
 * @Date 2023-02-22 17:32
 */
@Component
public class MyBeanPostProcessor implements BeanPostProcessor {

    //初始化之前调用
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("初始化之前调用...postProcessBeforeInitialization"+beanName+"=>"+bean);
        return bean;
    }

    //初始化之后调用
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("初始化之后调用....postProcessAfterInitialization"+beanName+"=>"+bean);
        return bean;
    }
}
